#include <iostream>

#include <stack>


 

using namespace std;

 

char *itoa(int,char,int);

 

string crpt(string&);

/*
int ____main (int argc, char * const argv[]) {

    string user,pass;
    
        while(true){
        
                cout<<"Please Enter the Username:"<<endl;
                
                cin>>user;
                
                cout<<"Please Enter the Oril-Password:"<<endl;
                
                cin>>pass;
                
                cout<<endl<<"The coded infor are:"<<endl;
                
                cout<<"username:"<<"^^"<<user<<endl;
                
                pass=crpt(pass);
                
                cout<<"Password:"<<pass<<endl<<endl;
        
         
    
     
    
    }
    
        return 0;

}
*/

 

 

CString dec2hex(int dec)

{
	char ch[100];

	itoa(dec,ch,16);
	
	CString str;

	str=ch;
	str.MakeUpper();

	return str;

 

    

}

 

CString crpt(CString &pass){

    //int s[8]={210,166,224,156,173,147,134,191};
    
    int s[8]={0xD2,0xA6,0xE0,0x9C,0xAD,0x93,0x86,0xBF};
    
    int ans[8]={0,0,0,0,0,0,0,0};
    
    CString an="";
    
    int i;
    CString tmp;
    for(i=0;i<8&&i<pass.GetLength ();i++){
	tmp="";

        ans[i]=(pass[i]^s[i]);
        
        
        
        tmp=dec2hex(ans[i]);
        
        an+=tmp;
    
    }
    
    for(int j=i;j<pass.GetLength ();j++){
    
        an+=pass[j];
    
    }
    
    return an;

}
